<html>
<head><meta charset="utf-8"><title>multiple lints targeting the same span · t-compiler/wg-diagnostics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/index.html">t-compiler/wg-diagnostics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span.html">multiple lints targeting the same span</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214517130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/multiple%20lints%20targeting%20the%20same%20span/near/214517130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Broto <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span.html#214517130">(Oct 25 2020 at 22:47)</a>:</h4>
<p>Clippy tries to avoid triggering multiple lints on the same span to avoid giving conflicting suggestions. This can be confusing for the user, and rustfix would also fail after the first suggestion. Right now this is handled "manually" on a case-by-case basis, which is error prone.</p>
<p>Is this problematic handled in a more general way in rustc? If it's not, any idea about how that should be implemented?</p>
<p>Thanks!</p>



<a name="214647644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/multiple%20lints%20targeting%20the%20same%20span/near/214647644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Broto <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span.html#214647644">(Oct 27 2020 at 00:02)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119031">@Esteban Küber</span> (sorry for the ping if not relevant)</p>



<a name="214879350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/multiple%20lints%20targeting%20the%20same%20span/near/214879350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span.html#214879350">(Oct 28 2020 at 18:30)</a>:</h4>
<p>This is indeed a problem that we haven't taken a principled way to solve yet <span class="user-mention" data-user-id="279272">@Eduardo Broto</span> <br>
I believe that we'd need people to take some time to come up with a workable solution, but there has been very little movement in that front.</p>



<a name="214981799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/multiple%20lints%20targeting%20the%20same%20span/near/214981799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span.html#214981799">(Oct 29 2020 at 15:22)</a>:</h4>
<p>What I thought about was  adding something like <code>linted_for_span(LINT_NAME, span)</code> to <code>rustc_session::Session</code>. We could maybe do this similar to the <code>one_time_diagnostics</code> field there: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/struct.Session.html#structfield.one_time_diagnostics">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/struct.Session.html#structfield.one_time_diagnostics</a></p>
<p>This  would involve a <code>FxHashSet&lt;(LintId, Span)&gt;</code>, so it shouldn't have much perf regressions.</p>
<p>Or/in addition</p>
<p>We could add something to the linting machinery, where we can create dependent lints . If a lint is triggered all  other lints depending on that lint won't trigger.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>